import java.awt.*;
import java.awt.event.*;
import java.sql.*;

@SuppressWarnings("serial")
public class Progress extends Frame implements ActionListener, ItemListener{
	public static final int  NONE   = 0;
	public static final int  ADD    = 1;
	public static final int  DELETE = 2;
	public static final int  SEARCH = 3;
	public static final int  TOTAL  = 4;
	
	public static TextArea  display;
	public static TextField  Ename;
	public static Choice Csn;
	public static Button     add, delete, search, total, etc, cancel;
	public static Connection con;
	public static Statement  stat;
	public static int        cmd, ytemp, smtemp;
	public static ResultSet rs = null;
	public static TextField        tf_temp;
	public static Choice        ch_temp;
	
	public Progress() {
		super("Progress");
		init();
		setLayout(new BorderLayout());
		display = new TextArea();
		display.setEditable(false);
		
		Panel left = new Panel();
		left.setLayout(new GridLayout(5,1));
		
		Panel cs = new Panel();
		cs.add(new Label("Course"));
		cs.add(Csn = new Choice());
		
		left.add(cs);
		addWindowListener(new WindowAdapter() {
			public void windowClosing(WindowEvent e) {
				destroy();
				setVisible(false);
				dispose();
				//System.exit(0);
			}
		});
		add("Center", display);
		add("West", left);
		//add("South", bottom);
		cmd = NONE;
		initialize();
	}

	private void init() {
		try{
			Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
		}catch(ClassNotFoundException ce){
			System.out.println(ce);
		}
		try{
			con =DriverManager.getConnection("jdbc:sqlserver://localhost:1433;databaseName=Seoyoung", "sa", "pw");
			System.out.println("You access DBMS because of Diary");
			stat = con.createStatement();
		}catch(SQLException se){
			System.out.println(se);
		}finally{
			//try{
			//}catch(SQLException se){}
		}
		
	}


	public void initialize() {
		
		
	}

	private void destroy() {
		try {
			if(stat != null) {
				stat.close();
			}
			if(con != null) {
				con.close();
			}
			if(rs != null){
				rs.close();
			}
		} catch(Exception ex) { }
	}

	public static void setEditable(int n) {
	
	}	
	

	public static void setEnable(int n) {
		
		
	}

	public void clear() {
		
		
	}

	public void actionPerformed(ActionEvent e) {
		
		return;
	}
	public void itemStateChanged(ItemEvent e){
		
		return;
	}
	
}
